const apiHost = 'http://121.5.163.3:3001';

export default {
  get(subway, data){
    let query = '';
    for(let i in data){
      if(data[i] != '')
        query = query+'&'+i+'='+data[i];
    }
    if(query != '') query = '?'+query.substr(1,query.length);
    return uni.request({
      url: apiHost+subway+query,
      method: 'GET'
    });
  },
  
  post(url, data){
    return uni.request({
      url: apiHost+url,
      method: 'POST',
      data
    });
  },
  
  put(url, data){
    return uni.request({
      url: apiHost+url,
      method: 'PUT',
      data
    });
  },
  
  delete(url, data){
    return uni.request({
      url: apiHost+url,
      method: 'DELETE',
      data
    });
  }
}